
const service = axios.create({
    baseURL:'/',
    timeout:3000
})
//请求之前
service.interceptors.request.use(async (config)=>{
    return config;
},(error)=>{
    return Promise.reject(error)
})

//响应数据
service.interceptors.response.use((response)=>{
    let {status,message} = response;
    console.log(response)
    if(status!==200){
        this.$message({message:message||'error-'+status,type:'error'})
    }else if(typeof(response.data)!=='object'){
        window.location.href="login.html"
    }
    return response;
},(error)=>{
    return Promise.reject(error)
})

Vue.prototype.http = service;

